package com.treemapdemo;

import java.util.TreeMap;

public class TreeMapDemo2 {
    public static void main(String[] args) {
        /*
        TreeMap集合:基本应用
        需求2:
            键:学生对象
            值:籍贯
            要求:按照学生年龄的升序排列，年龄一样按照姓名的字母排列，同姓名年龄视为同一个人
         */
        //1.创建集合
        TreeMap<Student, String> treeMap = new TreeMap<>();

        //2.创建学生对象
        Student student1 = new Student("zhangsan", 23);
        Student student2 = new Student("lishi", 24);
        Student student3 = new Student("wangwu", 25);

        //3.添加元素
        treeMap.put(student1,"江苏");
        treeMap.put(student2,"天津");
        treeMap.put(student3,"北京");

        //4.打印集合
        System.out.println(treeMap);

    }
}
